package chapter03




/**
  * @Copyright: Shanghai Definesys Company.All rights reserved.
  * @Description:
  * @author: chuhaitao
  * @since: 2019/1/1 16:40
  * @history:
  *          1.2019/1/1 created by chuhaitao
  */
object ForDemo {

  def main(args: Array[String]): Unit = {

    for (i <- 1 to 3 if i != 2) {
      print(i)
    }


    for (i <- 1 until 10 if 1 != 2) {
      print("hellow" + i)
    }


    //将yield 后面的返回值循环的放入到一个集合中
    var yars = for (i <- 1 to 10) yield {
      if (i / 2 == 0) 4 else 5
    }

    printf("yars" + yars)



    for (i <- Range(1,10 ,2)){
      printf("--"+i)
    }
  }





}
